
// 	if(getCookie("phoneNumber") != ""){
// 		let loadAndRegist=document.querySelector(".loadAndRegist");
// 			loadAndRegist.innerHTML="你好"+" "+getCookie("phoneNumber");
// 	}


let smallBox=document.querySelector(".informationLeft-2");
let bigBox=document.querySelector(".informationLeft-3");
let mask=document.querySelector(".informationLeft-4")
class MF {
		constructor(newSmallBox, newBigBox, newMask) {
			this.smallBox = newSmallBox;
			this.bigBox = newBigBox;
			this.mask = newMask;
			this.eventBind();
		}

		onmouseover() {
			let that = this;
			this.smallBox.onmouseover = function() {
				that.mask.style.display = "block";
				that.bigBox.style.display = "block";
			}
		}

		onmouseout() {
			let that = this;
			this.smallBox.onmouseout = function() {
				that.mask.style.display = "none";
				that.bigBox.style.display = "none";
			}
		}

		onmousemove() {
			let that = this;
			this.smallBox.onmousemove = function(evt) {
				let e = evt || event;
				

				let left = e.pageX - this.offsetLeft - that.mask.offsetWidth / 2;
				let top = e.pageY - that.smallBox.offsetTop - that.mask.offsetHeight / 2;

				if (left < 0) {
					left = 0;
				}

				let maxLeft = this.offsetWidth - that.mask.offsetWidth;

				if (left > maxLeft) {
					left = maxLeft;
				}

				let maxTop = this.offsetHeight - that.mask.offsetHeight;

				if (top > maxTop) {
					top = maxTop;
				}

				if (top < 0) {
					top = 0;
				}

				let x = that.bigBox.offsetWidth * left / that.mask.offsetWidth;
				let y = that.bigBox.offsetHeight * top / that.mask.offsetHeight;

				that.bigBox.style.backgroundPositionX = -x + "px";
				that.bigBox.style.backgroundPositionY = -y + "px";

				that.mask.style.left = left + "px";
				that.mask.style.top = top + "px";
			}
		}

		eventBind() {
			this.onmouseover();
			this.onmouseout();
			this.onmousemove();
		}
	}
let newMf=new MF(smallBox,bigBox,mask)

function mouseChange(obj){
	obj.hover(function(){
		obj.css({
			cursor: "pointer"
		})
	},function(){
		obj.css({
			cursor:"auto"
		})
	})
}
mouseChange($(".informationLeft-1 img,.addwait-1-1,.addwait-1-2,.addwait-1-3,.addwait-2,.joinclub,.addwait-3"))

function bgcchange(obj){
	obj.hover(function(){
		$(this).css({
			backgroundColor: "lightgray"
		})
	},function(){
		$(this).css({
			backgroundColor: "white"
		})
	})
}
bgcchange($(".changebgc"));

function Numchange(){
	let less=document.querySelector(".addwait-1-1");
	let Num=document.querySelector(".addwait-1-2");
	let more=document.querySelector(".addwait-1-3");
	let point=document.querySelector(".mypoint-3")
	less.onclick=function(){
		if(Num.innerHTML>0){
			Num.innerHTML-=1;
		}	
	}
	more.onclick=function(){
		Num.innerHTML=Number(Num.innerHTML)+1;
	}
	point.innerHTML=Number(Num.innerHTML) *335;
}
Numchange();

function addtocart(obj){
	obj.click(function(){
		$.ajax({
				url:"morebody.php",
				data:{
					goodsName:"圣罗兰口红",
					goodsNum:Number($(".addwait-1-2").html()) ,
					// name:$(".registeName input").val()
				},
				type:"get",
				success:function(resText){
					console.log(resText)
					if(resText==1){
					alert("添加成功")
				}
			}
		})
	})
}
addtocart($(".addwait-2"))

$(".link-2-3").click(function(){
	window.location.href="cart.html"
})